home *** CD-ROM | disk | FTP | other *** search
/ Hot Metal Pro 4.0 / Hot Metal Pro 4.0.iso / HMPRO4 / cgi.z / ssi_img.pl < prev    next >
Encoding:
Perl Script  |  1997-06-20  |  1.8 KB  |  74 lines

  1. #!/bin/perl
  2. # Random Image Displayer With Link Flexibility
  3. # Built for use with Server Side Includes
  4. # Created by: Matt Wright    mattw@misha.net
  5. # Version 1.2
  6. # Created On: 7/1/95            Last Modified: 11/4/95
  7. # The file README contains more information and installation instructions.
  8.  
  9. ###############################################
  10. # Define Variables
  11.  
  12. $basedir = "http://yourserver/~yourusername/images/";
  13.  
  14. @images = ("image1.gif","image2.gif","image3.gif");
  15.  
  16. @urls = ("http://www.sq.com/",
  17.           "http://www.somewhere.com/",
  18.           "http://www.somewhereelse.com/");
  19.  
  20. @alt = ("First WWW Page","Second WWW Page","Third WWW Page");
  21.  
  22. # Done
  23. ###############################################
  24.  
  25. ###############################################
  26. # Options
  27. $uselog = "0";            # 1 = YES; 0 = NO
  28.    $logfile = "/path/to/log/file";
  29.    $date = `/bin/date`; chop($date);
  30.  
  31. $link_image = "1";        # 1 = YES; 0 = NO
  32. $align = "left";
  33. $border = "2";
  34.  
  35. # Done
  36. ###############################################
  37.  
  38. srand(time ^ $$);
  39. $num = rand(@images); # Pick a Random Number
  40.  
  41. # Print Out Header With Random Filename and Base Directory
  42. #
  43. # if you find your page is not returning HTML, then remove the # 
  44. # from the following line  (kt)
  45. # print "Content-type: text/html\n\n";
  46. if ($link_image eq '1' && $urls[$num] ne "") {
  47.    print "<a href=\"$urls[$num]\">";
  48. }
  49.  
  50. print "<img src=\"$basedir$images[$num]\"";
  51. if ($border ne "") {
  52.    print " border=$border";
  53. }
  54. if ($align ne "") {
  55.    print " align=$align";
  56. }
  57. if ($alt[$num] ne "") {
  58.    print " alt=\"$alt[$num]\"";
  59. }
  60. print ">";
  61.  
  62. if ($link_image eq '1' && $urls[$num] ne "") {
  63.    print "</a>";
  64. }
  65.  
  66. print "\n";
  67.  
  68. # If You want a log, we add to it here.
  69. if ($uselog eq '1') {
  70.    open(LOG, ">>$logfile");
  71.    print LOG "$images[$num] - $date - $ENV{'REMOTE_HOST'}\n";
  72.    close(LOG);
  73. }
  74.